package com.wg.net;

import com.wg.net.operations.base.OperationRequest;
import com.wg.net.operations.base.OperationResponse;
import com.wg.net.operations.base.S2SOperationRequest;
import com.wg.net.operations.base.S2SOperationResponse;

/**
 * 错误帮助类
 *
 * @author 少爷123
 */
public class ErrorHelper {
    /**
     * 构建S2S操作响应
     *
     * @param request   请求
     * @param errorCode 错误码
     * @param errorDesc 错误描述
     * @return 响应
     */
    public static S2SOperationResponse buildS2SResponse(S2SOperationRequest request, short errorCode,
            String errorDesc) {
        S2SOperationResponse response = new S2SOperationResponse(request);
        response.setReturnCode(errorCode);
        response.setDebugMsg(errorDesc);
        return response;
    }

    /**
     * 构建操作响应
     *
     * @param request   请求
     * @param errorCode 错误码
     * @param errorDesc 错误描述
     * @return 响应
     */
    public static OperationResponse buildResponse(OperationRequest request, short errorCode, String errorDesc) {
        OperationResponse response = new OperationResponse(request.getOpCode());
        response.setReturnCode(errorCode);
        response.setDebugMsg(errorDesc);
        return response;
    }
}
